extends Spatial


# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var x_sensitivity = 0
var y_sensitivity = 0
var is_drag = false
var planet
var helper
var camera
var zoom

func _input(event):
	if event is InputEventMouseButton:
		if event.button_index == BUTTON_RIGHT:
			is_drag = event.pressed
		if event.button_index == BUTTON_WHEEL_UP and zoom > 0.1:
			zoom -= .1
			camera.translation = Vector3(0,0,zoom*zoom*zoom*zoom+1.1)
		if event.button_index == BUTTON_WHEEL_DOWN:
			zoom += .1
			#print(zoom)
			camera.translation = Vector3(0,0,zoom*zoom*zoom*zoom+1.1)

	if event is InputEventMouseMotion and is_drag:
		self.rotate_y(event.relative.x/x_sensitivity)
		helper.rotate_x(event.relative.y/y_sensitivity)

# Called when the node enters the scene tree for the first time.
func _ready():
	x_sensitivity = -200
	y_sensitivity = -200
	helper = get_node("helper")
	camera = get_node("helper/target")
	zoom = 2
	camera.translation = Vector3(0,0,zoom*zoom*zoom*zoom+1.1)
	pass # Replace with function body.
